<?php
/**
 * Created by PhpStorm.
 * User: eeo
 * Date: 2017/6/5
 * Time: 14:18
 */

namespace App\Model\Foundation;


use Illuminate\Database\Eloquent\Model;

class TeacherCourseType extends Model
{
    # 数据表
    protected $table = 'teacher_coursetype';

    # PK
    protected $primaryKey = 'id';

    public $timestamps = false;

    # fillable fields
    protected $fillable = [
        'teacheruid',
        'coursetypeid',
    ];

    /**
     * 根据teacherId获取课程id
     * @param $id  teacherID
     * @return array
     */
    static function getCourseTypeIds($id){
        $list = static::where('teacheruid',$id)->pluck('coursetypeid');
        return $list->toArray();
    }

    /**
     * 根据课程类型Id获取teacherid
     * @param   $id courseTypeId
     * @return array
     */
    static function getTeacherIds($id){
        if($id){
            $list = static::where('coursetypeid',$id)->pluck('teacheruid');
        }else{
            $list = static::whereNotNull('id')->pluck('teacheruid');
        }

        return $list->toArray();
    }







}